const Router = require('koa-router');
// 导入控制层
const {create, avatarInfo, coverInfo, remove, update, setPassword, setCreed} = require('../controller/user.controller');
const {updatePassword} = require('../service/user.service');

// 中间件
const {verifyAuth} = require('../middleware/auth.middleware');
const {verifyUser, handlePassword} = require('../middleware/user.middleware');

const userRouter = new Router({prefix: "/users"}); // 添加路由前缀

// 创建一个用户
userRouter.post("/", verifyUser, handlePassword, create);
// 获取用户头像
userRouter.get("/:userId/avatar", avatarInfo);
// 获取cover图片
userRouter.get("/:userId/cover", coverInfo);
// 注销一个账号
userRouter.delete("/", verifyAuth, remove);
// 修改博客是否开放
userRouter.patch("/private/:isPrivate", verifyAuth, update);
// 修改密码
userRouter.patch("/", verifyAuth, setPassword, updatePassword);
// 设置我的信条
userRouter.patch("/creed", verifyAuth, setCreed)
module.exports = userRouter;
